<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>模板配置</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="../../../../resources/lib/bui/css/dpl-min.css"
          th:href="@{/resources/lib/bui/css/dpl-min.css}"
          rel="stylesheet" />
    <link href="../../../../resources/lib/bui/css/bui-min.css"
          th:href="@{/resources/lib/bui/css/bui-min.css}"
          rel="stylesheet" />
    <link href="../../../../resources/lib/bui/css/bui-min.css"
          th:href="@{/resources/lib/bui/css/layout-min.css}"
          rel="stylesheet" />
    <script src="../../../../resources/lib/bui/js/jquery-1.8.1.min.js"
            th:src="@{/resources/lib/bui/js/jquery-1.8.1.min.js}"></script>
    <script src="../../../../resources/lib/bui/js/bui-min.js"
            th:src="@{/resources/lib/bui/js/bui-min.js}"></script>
    <script src="../../../../resources/lib/jquery/jquery.form.min.js"
            th:src="@{/resources/lib/jquery/jquery.form.min.js}"></script>
    <script src="../../../../resources/lib/jquery/jquery.util.js"
            th:src="@{/resources/lib/jquery/jquery.util.js}"></script>

</head>
<body th:fragment="setting">
<div id="templateChoseDiv" class="span16 hide">
    <form id="templateChoseForm" class="form-horizontal" style="margin-left: 10px;" action="">
        <div class="row">
            <div class="control-group span8">
                <table>
                    <tr>
                        <td><img id="1" src="../../../../resources/img/1.jpg"></td>
                        <td><img id="2" src="../../../../resources/img/2.jpg"></td>
                        <td><img id="3" src="../../../../resources/img/3.jpg"></td>
                        <td><img id="5" src="../../../../resources/img/5.jpg"></td>
                    </tr>
                    <tr>
                        <td style="text-align: center"><input type="radio" name="template" value="1" checked>&nbsp;&nbsp;单窗口</td>
                        <td style="text-align: center"><input type="radio" name="template" value="2">&nbsp;&nbsp;双窗口</td>
                        <td style="text-align: center"><input type="radio" name="template" value="3">&nbsp;&nbsp;三窗口</td>
                        <td style="text-align: center"><input type="radio" name="template" value="5">&nbsp;&nbsp;五窗口</td>
                    </tr>
                    <tr>
                        <label style="color: #ff0000;font-size: 14px;font-weight: bold">*窗口模板选择前，必须保存功能导航。</label>
                    </tr>
                </table>
            </div>
        </div>
    </form>
</div>
<script th:inline="javascript" type="text/javascript">
    var BASE_URL = /*[[@{/}]]*/ '/';
    var templateSettingForm = null;
    var treeMenu = null;
    var nodeId = /*[[${nodeId}]]*/true;
    var modelCount = /*[[${modelCount}]]*/true;
    var type = /*[[${type}]]*/true;
//    var url1 = /*[[${url1}]]*/true;
//    var url2 = /*[[${url2}]]*/true;
//    var url3 = /*[[${url3}]]*/true;
//    var url4 = /*[[${url4}]]*/true;
//    var url5 = /*[[${url5}]]*/true;
    function showTemplate(){
       // dialog.show();
        treeMenu = null;
        BUI.use('bui/data',function(Data){
            var Ajax = Data.Proxy.Ajax;
            var ajax = new Ajax({
                url:BASE_URL+'nh/template/template_setting/updateModelCount'
            });
            ajax.read({nodeId:nodeId,modelCount:modelCount},function(data){
                choseTemplate(modelCount.toString());
                //dialog.hide();
            },this)
        });
    }
    function findInitInfor(nodeId){
        BUI.use('bui/data',function(Data){
            var Ajax = Data.Proxy.Ajax;
            var ajax = new Ajax({
                url:BASE_URL+'nh/template/template_setting/findNodeInforByNodeId'
            });
            ajax.read({nodeId:nodeId},function(data){
                if(data!=null){
                    if(data.modelCount!=null){
                        treeMenu = data;
                        if(type=='show'){//只做显示
                            $('a').attr('style','display:none');
                            if(modelCount!=0){
                                choseTemplate(treeMenu.modelCount.toString());
                            }
                        }else if(type=='set'){//模板设置
                            $('a').attr('style','display:true');
                            if(treeMenu.modelCount== modelCount){
                                choseTemplate(treeMenu.modelCount.toString());
                            }else{
                                showTemplate();
                            }
                        }
                    }
                }
            },this)
        });
    }
    function checkImgType(imgName){
        var photoRegex = /\.jpg$|\.jpeg$|\.gif$|\.png$|\.bmp$|\.html$|\.htm$/i;//图片格式
        if(!photoRegex.test(imgName)){
            return false;
        }else{
            return true;
        }
    }
</script>
</body>
</html>